package model

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Phone    string `gorm:"type:char(11);not null;commit:'手机号'"`
	Password string `gorm:"type:char(32);not null;commit:'密码'"`
	NickName string `gorm:"type:varchar(50);not null;commit:'昵称'"`
	Email    string `gorm:"type:varchar(50);not null;commit:'邮箱'"`
	Image    string `gorm:"type:char(120);not null;commit:'图片'"`
	Status   int64  `gorm:"type:int;not null;commit:'0-正常,1-异常'"`
}
type Type struct {
	gorm.Model
	TypeName string `gorm:"type:char(120);not null;commit:'类型名称'"`
}

func (u *User) GetPhoneByPhone(db *gorm.DB, phone string) error {
	err := db.Where("phone=?", phone).Find(&u).Error
	return err
}
func (u *User) CreateUser(db *gorm.DB) error {
	err := db.Create(&u).Error
	return err
}
